package cn.edu.hbsi.dao;

import cn.edu.hbsi.domain.Orders;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrdersDao
{
    //根据订单id查询订单信息包括产品
    @Results({
            @Result(id = true,property = "oId",column = "id"),
            @Result(property = "oNumber",column = "number"),
            @Result(property = "products",column = "id",many = @Many(select = "cn.edu.hbsi.dao.ProductDao.selectProductByPId"))
    })
    @Select("select * from tb_orders where id=#{oId}")
    public Orders selectOrdersAndProductByOId(@Param("oId") Integer oId);

    @Results({
            @Result(id = true,property = "oId",column = "id"),
            @Result(property = "oNumber",column = "number")
    })
    @Select("select * from tb_orders where user_id=#{uId}")
    //根据用户id查询订单
    public List<Orders> selectOrdersByUId(@Param("uId") Integer uId);
}
